﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QuanLySuKien.model;
using System.Data.SqlClient;
using System.Web.Security;

namespace QuanLySuKien
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        
      

        protected void InsertCancelButton_Click(object sender, EventArgs e)
        {          
            HoTenTextBox.Text = String.Empty;
            NgaySinhTextBox.Text = String.Empty;
            SoDTTextBox.Text = String.Empty;
            EmailTextBox.Text = String.Empty;
            DiaChiTextBox.Text = String.Empty;
            MoTaTextBox.Text = String.Empty;
        }

        protected void ButtonInsert_Click(object sender, EventArgs e)
        {
            string HoTen = HoTenTextBox.Text.ToString();
            string NgaySinh = NgaySinhTextBox.Text.ToString();
            string SoDT = SoDTTextBox.Text.ToString();
            string Email = EmailTextBox.Text.ToString();
            string DiaChi = DiaChiTextBox.Text.ToString();
            string MoTa = MoTaTextBox.Text.ToString();
            try
            {
                //dang ky
                Membership.CreateUser(UserNameTextBox.Text, PassWordTextBox.Text, EmailTextBox.Text);


                if (ThongTinKHDAC.InsertKhachHang(UserNameTextBox.Text, HoTen, NgaySinh, SoDT, Email, DiaChi, MoTa))
                {
                    StatusLabel.Text = "Thành công ";
                    HoTenTextBox.Text = String.Empty;
                    NgaySinhTextBox.Text = String.Empty;
                    SoDTTextBox.Text = String.Empty;
                    EmailTextBox.Text = String.Empty;
                    DiaChiTextBox.Text = String.Empty;
                    MoTaTextBox.Text = String.Empty;
                }
                else
                {
                    StatusLabel.Text = "Mời bạn thử lại";
                }
            }
            catch (SqlException ex)
            {
                StatusLabel.Text = ex.Message;
            }
        }
    }
}